package com.tomek.ktoryoperator.utils;

import java.text.Collator;
import java.util.Comparator;
import java.util.Locale;

import android.content.Context;

import com.tomek.ktoryoperator.R;

public class Utils {
	public static final Collator PL_COLLATOR = Collator.getInstance(new Locale("PL"));
	public static final Comparator<String> PL_STRING_COMPARATOR = new PlStringComparator();

	public static int comparePL(String s1, String s2) {
		return PL_COLLATOR.compare(s1.toLowerCase(), s2.toLowerCase());
	}

	private static class PlStringComparator implements Comparator<String> {
		public final int compare(String a, String b) {
			return comparePL(a, b);
		}
	}
	
	public static String getNetworkTypeString(Context context, String value) {
		if (value == null) {
			return context.getResources().getString(R.string.no_operator);
		} else {
			return value;
		}
	}

}